package opera;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-12-05
 * Time: 15:37
 */
public class FindOperation implements IOperation{

    @Override
    public void Work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int curSize = bookList.getUseSize();
        for (int i = 0; i < curSize; i++) {
            Book book = bookList.getBooks(i);
            String bookName = book.getName();
            if (bookName.equals(name)) {
                System.out.println("找到了这本书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
